<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>医院排队叫号系统</title>
<style>
body {
	font-family: Arial, sans-serif;
	background-color: #f1f1f1;
}

.container {
	background-color: #fff;
	border-radius: 10px;
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
	padding: 20px;
	margin: auto;
	margin-top: 100px;
	max-width: 500px;
	text-align: center;
}

h1, h2 {
	color: #333;
	font-size: 32px;
	margin-bottom: 30px;
}

input[type="text"], input[type="password"],input[type="date"], select,
	#name, #IDcardno {
	border-radius: 4px;
	border: none;
	box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
	padding: 10px;
	margin: 10px 0;
	width: 98%;
}

input[type="submit"],input[type="button"] {
	background-color: #4CAF50;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	padding: 10px 20px;
	margin-top: 10px;
	font-size: 16px;
	transition: background-color 0.2s ease-in-out;
}

input[type="submit"]:hover,input[type="button"]:hover {
	background-color: #3e8e41;
}

#register-form {
	display: none;
}

#form-toggle {
	background-color: #f1f1f1;
	border: none;
	color: #666;
	cursor: pointer;
	font-size: 14px;
	margin-top: 10px;
	text-decoration: underline;
}
</style>
</head>
<body>
	<div class="container">
		<form id="login-form" action="${pageContext.request.contextPath}/Main" method="post">
			<h1>医院排队叫号管理系统</h1>
			<h2>登录</h2>
			<input type="text" placeholder="账号" name="account"> 
			<input type="password" placeholder="密码" name="password"> 
			<select name="type">
				<option value="" style="display: none;"></option>
				<option value="医生">医生</option>
				<option value="患者">患者</option>
				<option value="管理员">管理员</option>
			</select> <input type="hidden" name="action" value="pd">
			<input type="submit" value="登录">
			<p>
				没有账号? <a id="form-toggle" href="#" onclick="fun()">点击这里注册</a>
			</p>
		</form>
		<form id="register-form" action="${pageContext.request.contextPath}/Main" method="post">
			<h1>医院排队叫号管理系统</h1>
			<h2>注册</h2>
			<input type="text" id="account" name="account"placeholder="账号"> <input
				type="password" id="password" name="password"placeholder="密码"> <input
				type="password" id="password1" placeholder="确认密码"> 
				<input id="name" name="name" placeholder="姓名"> 
				<input type="text" id="idno" name="idno" placeholder="身份证号"> 
				<input type="text" id="tel" name="tel" placeholder="电话号码"> 
			性别：<select id="sex" name="sex">
				<option value="" style="display: none;"></option>
				<option value="男">男</option>
				<option value="女">女</option>
			</select>
			出生日期：<input type="date" id="date" name="date">
			<input type="hidden" name="action" value="addpatient">
			<input type="button" value="注册" onclick="fun1()">
			<p>
				注册成功？<a id="form-toggle" href="#" onclick="fun()">去登录</a>
			</p>
		</form>
	</div>
	<script>
	function fun() {
		var loginForm = document.getElementById('login-form');
		var registerForm = document.getElementById('register-form');
		var formToggle = document.getElementById('form-toggle');
		if (loginForm.style.display == 'none') {
			loginForm.style.display = 'block';
			registerForm.style.display = 'none';
			formToggle.innerText = '点击这里注册';
		} else {
			loginForm.style.display = 'none';
			registerForm.style.display = 'block';
			formToggle.innerText = '去登录';
		}
	};
	function fun1() {
		var account = document.getElementById('account');
		var password = document.getElementById('password');
		var password1 = document.getElementById('password1');
		var name = document.getElementById('name');
		var idno = document.getElementById('idno');
		var tel = document.getElementById('tel');
		var sex = document.getElementById('sex');
		var date = document.getElementById('date');
		var type = document.getElementById('type');
		var form = document.getElementById('register-form');
		if ("" == account.value || "" == password.value|| "" == password1.value || "" == name.value|| "" == idno.value||""==tel.value||""==sex.value||""==date.value||""==type.value) {
			alert("请填写完整信息");
		} else {
			if(password.value==password1.value){
				alert("注册成功");
				form.submit();
			}else{
				alert("两次密码不一致");
			}
		}
		var today = new Date();
		  today.setDate(today.getDate());  // 获取明天的日期
		  var dd = String(today.getDate()).padStart(2, '0');
		  var mm = String(today.getMonth() + 1).padStart(2, '0');  // 一月是 0
		  var yyyy = today.getFullYear();

		  var maxDate = yyyy + '-' + mm + '-' + dd;
		  var dateInput = document.getElementById("date");
		  dateInput.max = maxDate;
	}
	
</script>
</body>
</html>